<template>
  <div>
    <div class="list-btn">
      日期:<DatePicker type="date" @on-change="startTime"  placeholder="选择开始日期" style="width: 200px" ></DatePicker>
      ～<DatePicker type="date" @on-change="endTime"  placeholder="选择结束日期" style="width: 200px"></DatePicker>
    </div>
    <div class="list-btn">
      渠道:
      <Select style="width:200px" v-model="params.channelCode" >
        <!--<Option value=" ">全部</Option>-->
        <Option v-for="(item,index) in channelCodeList" :value="item.channelCode" :key="index">{{ item.channelName }}</Option>
      </Select>
    </div>
    <!-- <div class="list-btn">
      订单状态:
      <Select clearable style="width:200px" v-model="params.status" placeholder="请选择" @on-change="get(params.status)">
        <Option v-for="item in typeList" :value="item.id" :key="item.id">{{ item.name }}</Option>
      </Select>
    </div> -->
    <div class="list-btn">
      <Button type="primary" @click="getList(url,'refresh');get(params.channelCode)">搜索</Button>
    </div>
    <page-list :listTitle="listTitle" :list="list" :loading="loading" @selectItem="ids = $event;"></page-list>
    <page-button :current="params.pageCurrent"  :total="total" @changePageNum="params.pageCurrent = $event; getList(url)" @changePageSize="params.pageLimit = $event; getList(url)"></page-button>
  </div>
</template>

<script>
  import listMixin from '../../mixin/list'
  import pageList from '../../template/listTemplate'
  import pageButton from '../../template/pageBtnTemplate'
  import confirmDialog from '../../template/confirmDialogTemplate'
  export default {
    mixins:[listMixin],
    components: {
      pageList,
      pageButton,
      confirmDialog
    },
    methods:{
      get(s){
        console.log(s,'sss');
        if(s){
        this.$post('/bkchannel/data',{channelCode:s})
        .then((res) => {
          if(res.code === 0){
            this.channelName = res.data[0].channelName;
          }else{
            // this.$Message.error(res.msg);
          }
        }, (err) => {
          // this.loading = false;
          console.log(err);
        })
        }else{
          this.channelName = ""
        }

      }
    },
    mounted() {
      this.getChannel();
    },
    data () {
      return {
         tag: {
          'title': '新客转化率',
          'path': '/work/converRate/list'
        },
        channelName:'',
        listTitle: [
           {
            title: '注册日期',
            key: 'date',
            align:'center',
            minWidth:55,
             render: (h,params) =>{
              return h('div',this.getLocalDate(params.row.date))
            }
          },
           {
            title: '渠道',
            key: 'channelName',
            align:'center',
            minWidth:55,
           render:(h,params) => {
             return h('div', this.channelName?this.channelName:'全部')
          }
          },
           {
            title: '注册数',
            key: 'registerCount',
            align:'center',
            minWidth:55
          },
          {
            title: '实名认证数(率)',
            key:'iDCount',
            align:'center',
            minWidth:50,
            render: (h,params) =>{
              return h('div',`${params.row.iDCount} (${(params.row.iDRate*100).toFixed(2)}%)`)
            }
          },
          {
            title: '银行卡绑定数(率)',
            key: 'userBankCount',
            minWidth:50,
            align:'center',
            render: (h,params) =>{
              return h('div',`${params.row.userBankCount} (${(params.row.userBankRate*100).toFixed(2)}%)`)
            }
          },

          {
            title: '基本信息认证数(率)',
            key: 'userBasiceCount',
            align:'center',
            minWidth:55,
            render: (h,params) =>{
              return h('div',`${params.row.userBasiceCount} (${(params.row.userBasiceRate*100).toFixed(2)}%)`)
            }
          },
           {
            title: '运营商授权数(率)',
            key: 'userCarrierCount',
            align:'center',
            minWidth:50,
            render: (h,params) =>{
              return h('div',`${params.row.userCarrierCount} (${(params.row.userCarrierRate*100).toFixed(2)}%)`)
            }
          },
           {
            title: '芝麻分授权数(率)',
            key: 'zmfScoreCount',
            align:'center',
            minWidth:50,
            render: (h,params) =>{
              return h('div',`${params.row.zmfScoreCount} (${(params.row.zmfScoreRate*100).toFixed(2)}%)`)
            }
          },
           {
            title: '当日风控审核订单数(率)',
            key: 'userLoanCount',
            align:'center',
            minWidth:45,
            render: (h,params) =>{
              return h('div',`${params.row.userLoanCount} (${(params.row.userLoanRate*100).toFixed(2)}%)`)
            }
          },
           {
            title: '当日放款数(率)',
            key: 'userContractCount',
            align:'center',
            minWidth:45,
            render: (h,params) =>{
              return h('div',`${params.row.userContractCount} (${(params.row.userContractRate*100).toFixed(2)}%)`)
            }
          },
           {
            title: '当日放款金额(元)',
            key: 'userContractCount',
            align:'center',
            minWidth:45,
            render: (h,params) =>{
              return h('div',this.toYuan(params.row.userContractMoney))
            }
          },
        ],
        url: '/statistics/customer/conversionRate',
        nameListUrl: '',
        params: {
          //status:'',
          pageCurrent: 1,
          pageLimit: 10
        },

      }
    },
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
  .list-btn{
    margin-bottom: 5px;
    margin-right: 5px;
    display: inline-block;
  }
  .refresh-btn{
    float: right;
  }
/deep/ .ivu-table-cell {
    padding-left: 5px;
    padding-right: 5px;
}
</style>
